/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package edu.pku.sei.ocl.cst.impl;

import edu.pku.sei.ocl.cst.BlockOclExpressionCS;
import edu.pku.sei.ocl.cst.CSTPackage;
import edu.pku.sei.ocl.cst.OCLExpressionCS;
import edu.pku.sei.ocl.cst.SimpleNameCS;
import edu.pku.sei.ocl.cst.VariableCS;
import edu.pku.sei.ocl.evaluation.Context;
import edu.pku.sei.ocl.visitor.AbstractOCLVisitor;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Block Ocl Expression CS</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link edu.pku.sei.ocl.cst.impl.BlockOclExpressionCSImpl#getBody <em>Body</em>}</li>
 *   <li>{@link edu.pku.sei.ocl.cst.impl.BlockOclExpressionCSImpl#getVariables <em>Variables</em>}</li>
 *   <li>{@link edu.pku.sei.ocl.cst.impl.BlockOclExpressionCSImpl#getModifiers <em>Modifiers</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class BlockOclExpressionCSImpl extends OCLExpressionCSImpl implements
		BlockOclExpressionCS {
	/**
	 * The cached value of the '{@link #getBody() <em>Body</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBody()
	 * @generated
	 * @ordered
	 */
	protected EList<OCLExpressionCS> body;

	/**
	 * The cached value of the '{@link #getVariables() <em>Variables</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getVariables()
	 * @generated
	 * @ordered
	 */
	protected EList<VariableCS> variables;

	/**
	 * The cached value of the '{@link #getModifiers() <em>Modifiers</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getModifiers()
	 * @generated
	 * @ordered
	 */
	protected EList<SimpleNameCS> modifiers;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected BlockOclExpressionCSImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return CSTPackage.Literals.BLOCK_OCL_EXPRESSION_CS;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<OCLExpressionCS> getBody() {
		if (body == null) {
			body = new EObjectContainmentEList<OCLExpressionCS>(
					OCLExpressionCS.class, this,
					CSTPackage.BLOCK_OCL_EXPRESSION_CS__BODY);
		}
		return body;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<VariableCS> getVariables() {
		if (variables == null) {
			variables = new EObjectContainmentEList<VariableCS>(
					VariableCS.class, this,
					CSTPackage.BLOCK_OCL_EXPRESSION_CS__VARIABLES);
		}
		return variables;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<SimpleNameCS> getModifiers() {
		if (modifiers == null) {
			modifiers = new EObjectContainmentEList<SimpleNameCS>(
					SimpleNameCS.class, this,
					CSTPackage.BLOCK_OCL_EXPRESSION_CS__MODIFIERS);
		}
		return modifiers;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd,
			int featureID, NotificationChain msgs) {
		switch (featureID) {
		case CSTPackage.BLOCK_OCL_EXPRESSION_CS__BODY:
			return ((InternalEList<?>) getBody()).basicRemove(otherEnd, msgs);
		case CSTPackage.BLOCK_OCL_EXPRESSION_CS__VARIABLES:
			return ((InternalEList<?>) getVariables()).basicRemove(otherEnd,
					msgs);
		case CSTPackage.BLOCK_OCL_EXPRESSION_CS__MODIFIERS:
			return ((InternalEList<?>) getModifiers()).basicRemove(otherEnd,
					msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
		case CSTPackage.BLOCK_OCL_EXPRESSION_CS__BODY:
			return getBody();
		case CSTPackage.BLOCK_OCL_EXPRESSION_CS__VARIABLES:
			return getVariables();
		case CSTPackage.BLOCK_OCL_EXPRESSION_CS__MODIFIERS:
			return getModifiers();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
		case CSTPackage.BLOCK_OCL_EXPRESSION_CS__BODY:
			getBody().clear();
			getBody().addAll((Collection<? extends OCLExpressionCS>) newValue);
			return;
		case CSTPackage.BLOCK_OCL_EXPRESSION_CS__VARIABLES:
			getVariables().clear();
			getVariables().addAll((Collection<? extends VariableCS>) newValue);
			return;
		case CSTPackage.BLOCK_OCL_EXPRESSION_CS__MODIFIERS:
			getModifiers().clear();
			getModifiers()
					.addAll((Collection<? extends SimpleNameCS>) newValue);
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
		case CSTPackage.BLOCK_OCL_EXPRESSION_CS__BODY:
			getBody().clear();
			return;
		case CSTPackage.BLOCK_OCL_EXPRESSION_CS__VARIABLES:
			getVariables().clear();
			return;
		case CSTPackage.BLOCK_OCL_EXPRESSION_CS__MODIFIERS:
			getModifiers().clear();
			return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
		case CSTPackage.BLOCK_OCL_EXPRESSION_CS__BODY:
			return body != null && !body.isEmpty();
		case CSTPackage.BLOCK_OCL_EXPRESSION_CS__VARIABLES:
			return variables != null && !variables.isEmpty();
		case CSTPackage.BLOCK_OCL_EXPRESSION_CS__MODIFIERS:
			return modifiers != null && !modifiers.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	@Override
	public Object accept(AbstractOCLVisitor v, Context env, Object... argv) {
		if (argv == null || argv.length == 0) {
			return v.visitBlockOclExpressionCS(this, env);
		} else {
			return v.visitBlockOclExpressionCS(this, env, argv);
		}
	}

} //BlockOclExpressionCSImpl
